﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel;

namespace PSE.Updater.Common.Gateway.DataContract
{
    /// <summary>
    /// Tipos de pacote
    /// </summary>
    public enum PackageType
    {
        Hotfix = 0,
        ServicePack = 1,
        RTM = 2,
        Config = 3
    }

    /// <summary>
    /// Status de pacote
    /// </summary>
    public enum PackageStatus
    {
        Valid = 0,
        Invalid = 1,
        Missing = 2,
        New = 3,
        Installed = 4
    }

    /// <summary>
    /// Entidade que representa as informações de um Determinado Módulo
    /// </summary>
    [DataContract]
    public class ModuleUpdatePackage : INotifyPropertyChanged
    {
        /// <summary>
        /// Nome do arquivo (sem o caminho)
        /// </summary>
        [DataMember]
        public string FileName { get; set; }

        /// <summary>
        /// Nome do Systema
        /// </summary>
        [DataMember]
        public string SystemName { get; set; }

        /// <summary>
        /// Nome do Módulo
        /// </summary>
        [DataMember]
        public string ModuleName { get; set; }

        /// <summary>
        /// Versão do Módulo
        /// </summary>
        [DataMember]
        public string Version { get; set; }

        /// <summary>
        /// Tipo do Pacote
        /// </summary>
        [DataMember]
        public PackageType Type { get; set; }

        /// <summary>
        /// Descrição de Atualização
        /// </summary>
        [DataMember]
        public string UpdateDescription { get; set; }

        /// <summary>
        /// Tamanho do pacote
        /// </summary>
        [DataMember]
        public Int64 PackageSize { get; set; }


        public PackageStatus _status;
        /// <summary>
        /// Status do pacote, utilizado para indicar se um pacote pode ser instalado
        /// </summary>
        [DataMember]
        public PackageStatus Status
        {
            get
            {
                return _status;
            }
            set
            {
                _status = value;
                NotifyPropertyChanged("Status");
            }

        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion
    }
}
